package router

import (
	middleware "KumquatDrivesServices/Middleware"
	"KumquatDrivesServices/api"

	"github.com/gin-gonic/gin"
)

func AuthRouterInit(r *gin.RouterGroup) {
	authRouter := r.Group("/auth")

	authRouter.Use(middleware.AuthMiddleware)
	App := api.ApiGruopApp
	//用户模块
	{
		userApi := App.UserModuleApi
		userAuthRouter := authRouter.Group("/user")
		userAuthRouter.GET("/getUserInfo", userApi.GetUserInfo)
		userAuthRouter.PUT("/UpdateUserNickName", userApi.UpdateUserNickName)
		userAuthRouter.PUT("/UpdateUserPwd", userApi.UpdateUserPwd)
		userAuthRouter.DELETE("/Logout", userApi.Logout)
	}
	//文件模块
	{
		userFileApi := App.UserFileModuleApi
		userFileAuthRouter := authRouter.Group("/file")
		//文件上传
		{
			userFileAuthRouter.POST("/uploadFile", userFileApi.UploadFile)
			userFileAuthRouter.POST("/cancelUpload", userFileApi.CancelUpload)
			userFileAuthRouter.POST("/mergeFile", userFileApi.MergeFile)
		}
		//文件操作
		{
			userFileAuthRouter.POST("/createFolder", userFileApi.CreateFolder)
			userFileAuthRouter.GET("/getDirectoryContents", userFileApi.GetDirectoryContents)
			userFileAuthRouter.GET("/getPreviewId", userFileApi.GetPreviewId)
			userFileAuthRouter.GET("/getAllFolder", userFileApi.GetAllFolder)
			userFileAuthRouter.GET("/getDownloadCode", userFileApi.GetDownLoadCode)
			userFileAuthRouter.PUT("/reName", userFileApi.ReName)
			userFileAuthRouter.PUT("/moveFileOrFolder", userFileApi.MoveFileOrFolder)
			userFileAuthRouter.DELETE("/removeFiles", userFileApi.RemoveFiles)
		}
	}
	//分享模块
	{
		userShareApi := App.UserShareModuleApi
		userShareRouter := authRouter.Group("/share")
		{
			userShareRouter.POST("/createShareFile", userShareApi.CreateShareFile)
			userShareRouter.GET("/getShareList", userShareApi.GetShareList)
			userShareRouter.DELETE("/cancelShareFile", userShareApi.CancelShareFile)
		}
	}
	//回收站模块
	{
		userRecycleApi := App.UserRecycleModuleApi
		userRecycleRouter := authRouter.Group("/recycle")
		{
			userRecycleRouter.GET("/getRecycleFolderContents", userRecycleApi.GetRecycleFolderContents)
			userRecycleRouter.POST("/recoverFiles", userRecycleApi.RecoverFile)
			userRecycleRouter.DELETE("/deleteRecoverFile", userRecycleApi.DeleteRecoverFile)
		}
	}
}
